<?php
/**
 * @file
 * opac_features.features.inc
 */

/**
 * Implements hook_ctools_plugin_api().
 */
function opac_features_ctools_plugin_api($module = NULL, $api = NULL) {
  if ($module == "facetapi" && $api == "facetapi_defaults") {
    return array("version" => "1");
  }
  if ($module == "feeds" && $api == "feeds_importer_default") {
    return array("version" => "1");
  }
  if ($module == "feeds_tamper" && $api == "feeds_tamper_default") {
    return array("version" => "2");
  }
}

/**
 * Implements hook_views_api().
 */
function opac_features_views_api($module = NULL, $api = NULL) {
  return array("api" => "3.0");
}

/**
 * Implements hook_eck_bundle_info().
 */
function opac_features_eck_bundle_info() {
  $items = array(
    'biblio_biblio' => array(
      'machine_name' => 'biblio_biblio',
      'entity_type' => 'biblio',
      'name' => 'biblio',
      'label' => 'biblio',
      'config' => array(
        'managed_properties' => array(
          'title' => 'title',
          'isbn' => 'isbn',
          'bookrecno' => 'bookrecno',
          'booksize' => 'booksize',
          'booktype' => 'booktype',
          'callno' => 'callno',
          'classno' => 'classno',
          'cover' => 'cover',
          'notes' => 'notes',
          'lang' => 'lang',
          'page' => 'page',
          'price' => 'price',
          'primary_author' => 'primary_author',
          'author' => 'author',
          'publisher' => 'publisher',
          'pubdate' => 'pubdate',
          'subject' => 'subject',
          'title_proper' => 'title_proper',
          'finish' => 'finish',
          'created' => 0,
          'changed' => 0,
        ),
      ),
    ),
    'holding_holding' => array(
      'machine_name' => 'holding_holding',
      'entity_type' => 'holding',
      'name' => 'holding',
      'label' => 'holding',
      'config' => array(
        'managed_properties' => array(
          'title' => 'title',
          'barcode' => 'barcode',
          'callno' => 'callno',
          'checkman' => 0,
          'curlib' => 0,
          'curlocal' => 0,
          'orglib' => 0,
          'orglocal' => 0,
          'status' => 0,
          'volinfo' => 0,
          'checktime' => 0,
          'createdate' => 0,
          'regdate' => 0,
          'bindinfo' => 0,
        ),
      ),
    ),
  );
  return $items;
}

/**
 * Implements hook_eck_entity_type_info().
 */
function opac_features_eck_entity_type_info() {
  $items = array(
    'biblio' => array(
      'name' => 'biblio',
      'label' => 'biblio',
      'properties' => array(
        'title' => array(
          'label' => 'Title',
          'type' => 'text',
          'behavior' => 'title',
        ),
        'created' => array(
          'label' => 'Created',
          'type' => 'integer',
          'behavior' => 'created',
        ),
        'changed' => array(
          'label' => 'Changed',
          'type' => 'integer',
          'behavior' => 'changed',
        ),
        'isbn' => array(
          'label' => 'isbn',
          'type' => 'text',
          'behavior' => '',
        ),
        'bookrecno' => array(
          'label' => '书目号',
          'type' => 'positive_integer',
          'behavior' => '',
        ),
        'booksize' => array(
          'label' => '书目尺寸',
          'type' => 'text',
          'behavior' => '',
        ),
        'booktype' => array(
          'label' => '书目类型',
          'type' => 'text',
          'behavior' => '',
        ),
        'callno' => array(
          'label' => '索书号',
          'type' => 'text',
          'behavior' => '',
        ),
        'classno' => array(
          'label' => '分类号',
          'type' => 'text',
          'behavior' => '',
        ),
        'cover' => array(
          'label' => '封面',
          'type' => 'text',
          'behavior' => '',
        ),
        'notes' => array(
          'label' => '备注',
          'type' => 'text',
          'behavior' => '',
        ),
        'lang' => array(
          'label' => '语言',
          'type' => 'text',
          'behavior' => '',
        ),
        'page' => array(
          'label' => '页数',
          'type' => 'text',
          'behavior' => '',
        ),
        'price' => array(
          'label' => '价格',
          'type' => 'text',
          'behavior' => '',
        ),
        'primary_author' => array(
          'label' => '主要作者',
          'type' => 'text',
          'behavior' => '',
        ),
        'author' => array(
          'label' => '著者',
          'type' => 'text',
          'behavior' => '',
        ),
        'publisher' => array(
          'label' => '出版社',
          'type' => 'text',
          'behavior' => '',
        ),
        'pubdate' => array(
          'label' => '出版日期',
          'type' => 'text',
          'behavior' => '',
        ),
        'subject' => array(
          'label' => '主题',
          'type' => 'text',
          'behavior' => '',
        ),
        'title_proper' => array(
          'label' => 'title proper',
          'type' => 'text',
          'behavior' => '',
        ),
        'finish' => array(
          'label' => 'finish',
          'type' => 'integer',
          'behavior' => '',
        ),
      ),
    ),
    'holding' => array(
      'name' => 'holding',
      'label' => 'holding',
      'properties' => array(
        'title' => array(
          'label' => 'Title',
          'type' => 'text',
          'behavior' => 'title',
        ),
        'barcode' => array(
          'label' => 'Barcode',
          'type' => 'text',
          'behavior' => '',
        ),
        'callno' => array(
          'label' => '检索号',
          'type' => 'text',
          'behavior' => '',
        ),
        'checkman' => array(
          'label' => 'checkman',
          'type' => 'text',
          'behavior' => '',
        ),
        'curlib' => array(
          'label' => '当前图书馆',
          'type' => 'text',
          'behavior' => '',
        ),
        'curlocal' => array(
          'label' => '当前馆藏地',
          'type' => 'text',
          'behavior' => '',
        ),
        'orglib' => array(
          'label' => '原始图书馆',
          'type' => 'text',
          'behavior' => '',
        ),
        'orglocal' => array(
          'label' => '原始馆藏地',
          'type' => 'text',
          'behavior' => '',
        ),
        'status' => array(
          'label' => '状态',
          'type' => 'text',
          'behavior' => '',
        ),
        'volinfo' => array(
          'label' => '卷数',
          'type' => 'text',
          'behavior' => '',
        ),
        'checktime' => array(
          'label' => 'checktime',
          'type' => 'positive_integer',
          'behavior' => '',
        ),
        'createdate' => array(
          'label' => 'createdate',
          'type' => 'positive_integer',
          'behavior' => '',
        ),
        'regdate' => array(
          'label' => 'regdate',
          'type' => 'positive_integer',
          'behavior' => '',
        ),
        'bindinfo' => array(
          'label' => 'Bindinfo',
          'type' => 'text',
          'behavior' => '',
        ),
        'bookrecno' => array(
          'label' => '书目号',
          'type' => 'integer',
          'behavior' => '',
        ),
      ),
    ),
  );
  return $items;
}

/**
 * Implements hook_node_info().
 */
function opac_features_node_info() {
  $items = array(
    'biblio_feed' => array(
      'name' => t('Biblio feed'),
      'base' => 'node_content',
      'description' => '',
      'has_title' => '1',
      'title_label' => t('Title'),
      'help' => '',
    ),
    'holding_feed' => array(
      'name' => t('Holding feed'),
      'base' => 'node_content',
      'description' => '',
      'has_title' => '1',
      'title_label' => t('Title'),
      'help' => '',
    ),
  );
  drupal_alter('node_info', $items);
  return $items;
}

/**
 * Implements hook_default_search_api_index().
 */
function opac_features_default_search_api_index() {
  $items = array();
  $items['biblio'] = entity_import('search_api_index', '{
    "name" : "biblio index",
    "machine_name" : "biblio",
    "description" : null,
    "server" : "local_solr",
    "item_type" : "biblio",
    "options" : {
      "datasource" : { "bundles" : [] },
      "index_directly" : 0,
      "cron_limit" : "50",
      "fields" : {
        "author" : { "type" : "string" },
        "callno" : { "type" : "string" },
        "classno" : { "type" : "string" },
        "field_clc:description" : { "type" : "list\\u003Ctext\\u003E" },
        "field_clc:name" : { "type" : "list\\u003Cstring\\u003E" },
        "field_clc:parents_all" : {
          "type" : "list\\u003Clist\\u003Cinteger\\u003E\\u003E",
          "entity_type" : "taxonomy_term"
        },
        "field_holdings:curlib" : { "type" : "list\\u003Cstring\\u003E" },
        "field_holdings:curlocal" : { "type" : "list\\u003Cstring\\u003E" },
        "field_holdings:orglib" : { "type" : "list\\u003Cstring\\u003E" },
        "field_holdings:orglocal" : { "type" : "list\\u003Cstring\\u003E" },
        "field_holdings:status" : { "type" : "list\\u003Cstring\\u003E" },
        "isbn" : { "type" : "string" },
        "lang" : { "type" : "string" },
        "primary_author" : { "type" : "string" },
        "pubdate" : { "type" : "string" },
        "publisher" : { "type" : "string" },
        "search_api_aggregation_1" : { "type" : "text" },
        "search_api_language" : { "type" : "string" },
        "subject" : { "type" : "string" },
        "title" : { "type" : "text", "boost" : "8.0" },
        "title_proper" : { "type" : "text" }
      },
      "data_alter_callbacks" : {
        "search_api_alter_bundle_filter" : {
          "status" : 0,
          "weight" : "-10",
          "settings" : { "default" : "1", "bundles" : [] }
        },
        "search_api_alter_add_hierarchy" : { "status" : 0, "weight" : "0", "settings" : { "fields" : [] } },
        "search_api_alter_add_viewed_entity" : { "status" : 0, "weight" : "0", "settings" : { "mode" : "full" } },
        "search_api_alter_add_aggregation" : {
          "status" : 1,
          "weight" : "0",
          "settings" : { "fields" : { "search_api_aggregation_1" : {
                "name" : "topic",
                "type" : "fulltext",
                "separator" : "\\n\\n",
                "fields" : [ "subject" ],
                "description" : "A Fulltext aggregation of the following fields: \\u4e3b\\u9898."
              }
            }
          }
        },
        "search_api_alter_add_url" : { "status" : 0, "weight" : "0", "settings" : [] }
      },
      "processors" : {
        "search_api_case_ignore" : {
          "status" : 0,
          "weight" : "0",
          "settings" : { "fields" : { "title" : true } }
        },
        "search_api_html_filter" : {
          "status" : 0,
          "weight" : "10",
          "settings" : {
            "fields" : { "title" : true },
            "title" : 0,
            "alt" : 1,
            "tags" : "h1 = 5\\r\\nh2 = 3\\r\\nh3 = 2\\r\\nstrong = 2\\r\\nb = 2\\r\\nem = 1.5\\r\\nu = 1.5"
          }
        },
        "search_api_tokenizer" : {
          "status" : 1,
          "weight" : "20",
          "settings" : {
            "fields" : { "title" : true, "title_proper" : true },
            "spaces" : "[^[:alnum:]]",
            "ignorable" : "[\\u0027]"
          }
        },
        "search_api_stopwords" : {
          "status" : 0,
          "weight" : "30",
          "settings" : {
            "fields" : { "title" : true },
            "file" : "",
            "stopwords" : "but\\r\\ndid\\r\\nthe this that those\\r\\netc"
          }
        },
        "search_api_porter_stemmer" : {
          "status" : 0,
          "weight" : "35",
          "settings" : { "fields" : { "title" : true }, "exceptions" : "texan=texa" }
        },
        "search_api_highlighting" : {
          "status" : 0,
          "weight" : "40",
          "settings" : {
            "prefix" : "\\u003Cstrong\\u003E",
            "suffix" : "\\u003C\\/strong\\u003E",
            "excerpt" : 1,
            "excerpt_length" : "256",
            "exclude_fields" : [],
            "highlight" : "always",
            "highlight_partial" : 0
          }
        }
      }
    },
    "enabled" : "1",
    "read_only" : "0",
    "rdf_mapping" : []
  }');
  return $items;
}

/**
 * Implements hook_default_search_api_page().
 */
function opac_features_default_search_api_page() {
  $items = array();
  $items['search_biblio'] = entity_import('search_api_page', '{
    "index_id" : "biblio",
    "path" : "book-search",
    "name" : "search biblio",
    "machine_name" : "search_biblio",
    "description" : "",
    "options" : {
      "mode" : "single",
      "fields" : { "title" : "title", "title_proper" : "title_proper" },
      "per_page" : "20",
      "result_page_search_form" : 1,
      "get_per_page" : 0,
      "view_mode" : "search_api_page_result",
      "empty_behavior" : ""
    },
    "enabled" : "1",
    "rdf_mapping" : []
  }');
  return $items;
}
